# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pcre

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=8.35
pkgrel=1
pkgdesc="A library that implements Perl 5-style regular expressions (mingw-w64)"
arch=('any')
url="http://pcre.org"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-zlib" "${MINGW_PACKAGE_PREFIX}-bzip2") # "${MINGW_PACKAGE_PREFIX}-readline"
options=('staticlibs' 'strip')
source=(ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${_realname}-${pkgver}.tar.bz2{,.sig})
md5sums=('6aacb23986adccd9b3bc626c00979958'
         'SKIP')

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  CPPFLAGS+=" -I${MINGW_PREFIX}/include"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-unicode-properties \
    --enable-utf \
    --enable-pcre8 \
    --enable-pcre16 \
    --enable-pcre32 \
    --enable-pcregrep-libz \
    --enable-pcregrep-libbz2
  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  #rm -r "${pkgdir}${MINGW_PREFIX}/share"
}
